const {
  defineConfig
} = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: '',
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          modifyVars: {
            hack: 'true; @import "D:\\vue\\vue-elm\\src\\theme.less";'
          }
        }
      }
    }
  },
})

const path = require('path')
const themePath = path.join(__dirname, './src/theme.less')
module.exports = {
  //发布模式
  chainWebpack: config => {
    config.when(process.env.NODE_ENV === 'production', config => {
      config.entry('app').clear().add('./src/main-prod.js')
      config.set('externals', {
        vue: 'Vue',
        'vue-router': 'VueRouter',
        axios: 'axios',
        vuex: 'Vuex',
        vant: 'vant'
      })
      config.plugin('html').tap(args => {
        args[0].isProd = true
        return args
      })
    })
    // 开发模式
    config.when(process.env.NODE_ENV === 'development', config => {
      config.entry('app').clear().add('./src/main-dev.js')
      config.plugin('html').tap(args => {
        args[0].isProd = false
        return args
      })
    })
  },
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          modifyVars: {
            hack: 'true; @import "D:\\vue\\vue-elm\\src\\theme.less";'
          }
        }
      }
    }
  },
  devServer: {
    proxy: {
      '/api': {
        target: "https://elm.cangdu.org/",
        // secure: true,
        changeOrigin: true,
        // ws: true,
        pathRewrite: {
          '^/api': '',
        }
      }
    }
  },
  publicPath: ''
}